@isTest
public class QuoteProductHandlerTest {
    
    static testMethod void testMethod1() {
        
        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;     

        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;

        //报价1
        Quote qt1 = new Quote(Name = '仪器报价',Type__c = '仪器报价',OpportunityId = opp.Id);
        //报价2
        Quote qt2 = new Quote(Name = '试剂报价',Type__c = '试剂报价',OpportunityId = opp.Id);
        insert new Quote[] { qt1, qt2 };

        //产品1    
        Product__c p1 = TestUtils.createProduct();        
        p1.Category1__c = '微生物'; 
        p1.Purpose__c = '仪器报价用';
        p1.Brand__c = '迈克';
   
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
        p2.Purpose__c = '仪器报价用';
        p2.Brand__c = '迈克';

        p2.Category1__c = '免疫';        
        insert new Product__c[] {p1, p2};
        //报价产品1
        QuoteProduct__c qp1 = new QuoteProduct__c(Name = '测试报价产品1',Product__c = p1.Id,Quote__c = qt1.Id);        
        QuoteProduct__c qp2 = new QuoteProduct__c(Name = '测试报价产品2',Product__c = p2.Id,Quote__c = qt2.Id);
        insert new QuoteProduct__c[] {qp1,qp2};

        Opportunity insertOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
       // system.assertEquals('多项目', insertOpp.ProjectType__c);

        qp1.Comment__c = '321';

        System.Test.startTest();
        update qp1;
        delete qp1;
        qt2.Status = '申请中';
        update qt2;


         qt2.Status = '已批准' ;
        update qt2;

        System.Test.stopTest();
        //Opportunity deleteOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        //system.assertEquals('单项目', deleteOpp.ProjectType__c);
    }


    // static testMethod void testMethod2() {

    //     //客户2
    //     Account ac = TestUtils.createAccount();
    //     ac.Name = '测试客户1';
    //     ac.Level__c = '二级甲等';
    //     insert ac;

    //     //业务机会2
    //     Opportunity op = TestUtils.createOpportunity();
    //     op.AccountId = ac.Id;
    //     insert op;

    //     //报价2        
    //     Quote qt1 = new Quote(Name = '测试报价1',OpportunityId = op.Id);
    //     insert qt1;

    //     //产品2
    //     Product__c p11 = TestUtils.createProduct();
    //     p11.Purpose__c = '试剂报价用';
    //     p11.Category1__c = '微生物';    
    //     Product__c p22= TestUtils.createProduct();
    //     p22.Name = 'Test11';
    //     p22.Category1__c = '免疫';
    //     p22.Purpose__c = '试剂报价用';
    //     insert new Product__c[] {p11, p22};    

    //     //报价产品2
    //     QuoteProduct__c qp11 = new QuoteProduct__c(Name = '测试报价产品1',Product__c = p11.Id,Quote__c = qt1.Id);
    //     QuoteProduct__c qp22 = new QuoteProduct__c(Name = '测试报价产品2',Product__c = p22.Id,Quote__c = qt1.Id);
    //     insert new QuoteProduct__c[] {qp11,qp22};

    //     Opportunity insertOpp = [select ProjectType__c,id from Opportunity where id = :op.Id];
    //     system.assertEquals('多项目', insertOpp.ProjectType__c);

    //     qp11.Comment__c = '321';
    //     update qp11;        
    //     delete qp11;

    //     Opportunity updateOpp = [select ProjectType__c,id from Opportunity where id = :op.Id];
    //     system.assertEquals('单项目', updateOpp.ProjectType__c);
 

    // }
}